package cp3120.dao;

/**
 *
 * @author Adam Scarr <scarr.adam@gmail.com>
 */
public abstract class DAOFactory {
    private static DAOFactory instance;

    /**
     * Hybrid abstract factory/singleton pattern.
     * @return the instance of this factory
     */
    public static synchronized DAOFactory getFactory() {
        return instance;
    }

    /**
     * sets up the instance of this factory
     * @param factory the instance to be used
     */
    public static synchronized void setFactory(DAOFactory factory) {
        instance = factory;
    }

    /**
     * get's the implemtation of Flight DAO
     * @return the Flight DAO implemtation
     */
    public static FlightDAO getFlightDAO() {
        return getFactory().getFlightDAOImplementation();
    }

    /**
     * get's the implemtation of User DAO
     * @return the User DAO implemtation
     */
    public static UserDAO getUserDAO() {
        return getFactory().getUserDAOImplementation();
    }

    /**
      * get's the implemtation of Purchase DAO
      * @return the Purchase DAO implemtation
      */
    public static PurchaseDAO getPurchaseDAO() {
        return getFactory().getPurchaseDAOImplementation();
    }

    /**
      * get's the implemtation of Variable DAO
      * @return the Variable DAO implemtation
      */
    public static VariableDAO getVariableDAO() {
        return getFactory().getVariableDAOImplementation();
    }

    protected abstract FlightDAO getFlightDAOImplementation();
    protected abstract UserDAO getUserDAOImplementation();
    protected abstract PurchaseDAO getPurchaseDAOImplementation();
    protected abstract VariableDAO getVariableDAOImplementation();
}
